package com.gopay.bis.dao.payconfig.impl;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.springframework.stereotype.Repository;

import com.gopay.bis.dao.payconfig.BisBizProdSpTranBKConfigDAO;
import com.gopay.common.base.dao.impl.BaseDAOImpl;
import com.gopay.common.constants.txncd.IntTxnCd;
import com.gopay.common.domain.bis.BisBizProdSpTranBKConfig;

/**
 * 
 * @author liujy
 * 
 */
@Repository("bisBizProdSpTranBKConfigDAO")
public class BisBizProdSpTranBKConfigDAOImpl extends
		BaseDAOImpl<BisBizProdSpTranBKConfig, String> implements BisBizProdSpTranBKConfigDAO{

	@Override
	public List<BisBizProdSpTranBKConfig> findConfigsByBankBizProdsAndIntTxnCd(
			IntTxnCd intTxnCd, List<String> prods) {
		if(null == prods || prods.isEmpty()){
			return null;
		}
		String hql = "from BisBizProdSpTranBKConfig where gopayIntTxnCd =:intTxnCd and bankBizProdCode in (:prods) and b.enable=:enable";
		
		Map<String, Object> param = new HashMap<String, Object>();
		param.put("intTxnCd", intTxnCd.value);
		param.put("prods", prods);
		param.put("enable", true);
		
		return findByHql(hql, param);
	}

	@Override
	public List<BisBizProdSpTranBKConfig> findAll() {
		StringBuilder s = new StringBuilder("from BisBizProdSpTranBKConfig b where 1 = 1 and b.enable=:enable");
		
		Map<String, Object> param = new HashMap<String, Object>();
		param.put("enable", true);
		
		return findByHql(s.toString(), param);
	}

}
